#include <omp.h>
#include <stdio.h>
#define N 100
#define M 100

#pragma omp begin declare target
float Q[N][M];
float P(const int i, const int k) {
    return Q[i][k] * Q[k][i];
}
#pragma omp end declare target

float accum() {
    float temp = 0.0;
    int i, k;
    #pragma omp target update to(Q)
    #pragma omp target map(tofrom: temp)
    #pragma omp parallel for reduction(+:temp)
    for (i = 0; i < N; i++) {
        float tmp_local = 0.0;
        for (k = 0; k < M; k++) {
            tmp_local += P(i, k);
        }
        temp += tmp_local;
    }
    return temp;
}

int main() {
    int i, k;
    for (i = 0; i < N; i++) {
        for (k = 0; k < M; k++) {
            Q[i][k] = 1.0f;
        }
    }
    float result = accum();
    printf("Result: %.2f\n", result);
    return 0;
}